import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import {fileURLToPath} from 'node:url'

// https://vitejs.dev/config/

export default defineConfig(({mode, command}) => {
    const env = loadEnv(mode, process.cwd())
    return {
        base: env.VITE_APP_ENV === 'production' ? '/' : '/',
        plugins: [vue()],
        server: {
             host: '0.0.0.0',
             port: 7000,
            open: true,
            proxy: {
                '/api': {
                  //  ws: true,
                    target: 'http://127.0.0.1:18902',
                    changeOrigin: true,
                    rewrite: (p) => p.replace(/^\/api/, '')
                }
            }
        },
        resolve: {
            alias: {
                '@': fileURLToPath(new URL('./src', import.meta.url))
            }
        },

    }
})
